package edu.ciee.tz.dao;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.stereotype.Component;

import edu.ciee.tz.model.GouruEb;

@Component("gouruebDao")
public class GouruEbDAO {

	public List<GouruEb> search(GouruEb g) throws Exception {

		String query = "where 1=1";

		if (g.getId() != 0) 
			query = query + " and id like '%" + g.getId() + "%'";// this.getID()
		if (g.getEb_id()!= null) 
			query = query + " and gouru_time like '%" + g.getEb_id()+ "%'"; // this.getName()
		if (g.getGouru_id()!=null&&g.getGouru_id().getId()!= 0) 
			query = query + " and fz_person like '%" + g.getGouru_id().getId()+ "%'";// this.getID()
		@SuppressWarnings("unchecked")
		List<GouruEb> gouru_list = hibernateTemplate.find("from GouruEb u "+ query);

		return gouru_list;
	}

	public void insert(GouruEb z) throws Exception {
		this.getHibernateTemplate().save(z);
	}

	public void delete(GouruEb z) throws Exception {
		this.getHibernateTemplate().delete(z);

	}

	public void update(GouruEb z) throws Exception {
		this.getHibernateTemplate().update(z);
	}

	private HibernateTemplate hibernateTemplate;

	public HibernateTemplate getHibernateTemplate() {
		return hibernateTemplate;
	}

	@Resource
	public void setHibernateTemplate(HibernateTemplate hibernateTemplate) {
		this.hibernateTemplate = hibernateTemplate;
	}
}
